Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

neo4j-driver

Package Overview
Dependencies
Maintainers
2
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neo4j-driver

Connect to Neo4j 3.0.0 and up from JavaScript

  • 1.7.8
  • latest-1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
119K
decreased by-16.86%
Maintainers
2
Weekly downloads
 
Created

What is neo4j-driver?

The neo4j-driver npm package is a driver for connecting to and interacting with a Neo4j database from a Node.js application. It provides a set of tools and APIs to perform various operations such as connecting to the database, executing Cypher queries, managing transactions, and handling results.

What are neo4j-driver's main functionalities?

Connecting to Neo4j

This feature allows you to establish a connection to a Neo4j database using the Bolt protocol. You need to provide the database URL and authentication credentials.

const neo4j = require('neo4j-driver');
const driver = neo4j.driver('bolt://localhost:7687', neo4j.auth.basic('username', 'password'));
const session = driver.session();

Executing Cypher Queries

This feature enables you to execute Cypher queries against the connected Neo4j database. The example demonstrates running a simple query to match and return all nodes.

const result = await session.run('MATCH (n) RETURN n');
result.records.forEach(record => {
  console.log(record.get(0));
});

Managing Transactions

This feature allows you to manage transactions, providing a way to commit or rollback operations as needed. The example shows how to create a node within a transaction and handle errors.

const tx = session.beginTransaction();
try {
  await tx.run('CREATE (n:Person {name: $name})', { name: 'Alice' });
  await tx.commit();
} catch (error) {
  await tx.rollback();
  throw error;
}

Handling Results

This feature provides methods to handle and process the results returned from Cypher queries. The example demonstrates accessing and logging the properties of a node from the query result.

const result = await session.run('MATCH (n) RETURN n');
const singleRecord = result.records[0];
const node = singleRecord.get(0);
console.log(node.properties);

Other packages similar to neo4j-driver

FAQs

Package last updated on 02 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc